from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep, time, strftime

driver = webdriver.Firefox()
driver.maximize_window()
url = 'file:///C:/Users/tedu/Desktop/NSD2406/html/register.html'
driver.get(url)

driver.find_element(By.CSS_SELECTOR, '#user').send_keys('小明')
# 截屏
# 为了防止出现名称覆盖，使用时间作为文件名称
# 获取当前的时间戳
# print('时间戳：', time())
# 格式化时间，显示指定的格式  xxxx_xx_xx_xx_xx_xx
# print(strftime("%Y_%m_%d_%H_%M_%S"))
current_time = strftime("%Y_%m_%d_%H_%M_%S")

driver.get_screenshot_as_file(f'images/{current_time}.png')

sleep(3)
driver.quit()